package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.server.KsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class KsController {
    @Autowired
    private KsService ksservice;
    @PostMapping("/login")
    public Result login(@RequestBody User user){
        UserInfo userInfo = ksservice.login(user);
        if(userInfo==null){
          return Result.error("用户名或密码错误");
        }
          return Result.success(userInfo);

    }
    @GetMapping("/user")
    public Result getall(Page page){
        PageResult<User> pageResult;
        pageResult = ksservice.page1(page);
        return Result.success(pageResult);

    }
}
